package com.publish.file.service.auth;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;

public class UserRoleSecurityProvider implements AuthenticationProvider {
	@Autowired
	UserRoleManagerService managerService;
	private Logger logger = LoggerFactory.getLogger(getClass().getSimpleName());

	@Override
	public Authentication authenticate(Authentication authentication) throws AuthenticationException {
		SimpleAuthentication token = (SimpleAuthentication) authentication;
		UserRoleDetail detail = (UserRoleDetail) token.getPrincipal();
		if (detail.getUsername() == detail.getPassword()) {
			return token;
		}
		return null;
	}

	@Override
	public boolean supports(Class<?> authentication) {
		return (SimpleAuthentication.class.isAssignableFrom(authentication));
	}

}
